﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace IA2MazeSolver
{
    public class MazeDebug
    {
        public static bool Avaliacao = false;
        public static bool Geracao = false;
        public static bool Melhor = false;

        private static StringBuilder _debug;
        public static StringBuilder _Debug
        {
            get
            {
                if (MazeDebug._debug == null)
                {
                    MazeDebug._debug = new StringBuilder();
                }
                return MazeDebug._debug;
            }
        }

        public static void Write(String debug)
        {
            _Debug.Append(debug);
        }

        public static void WriteLine(String debug)
        {
            _Debug.AppendLine(debug);
        }

        public static void Clear()
        {
            _Debug.Clear();
        }

        public static String toString()
        {
            return _Debug.ToString();
        }

        public static void toOutput()
        {
            Debug.WriteLine(MazeDebug.toString());
        }

        public static void Populacao(List<Individuo> populacao)
        {
            for (int i = 0; i < populacao.Count(); i++)
            {
                MazeDebug.WriteLine(String.Format("[{0}] - {1}", populacao[i].Fitness, String.Join("", populacao[i].Data)));
            }
            MazeDebug.WriteLine("------------------");
        }

        public static void Individuo(Individuo individuo)
        {
            MazeDebug.WriteLine(String.Format("Fitness: {0}", individuo.Fitness));
            MazeDebug.WriteLine(String.Format("Size: {0}", individuo.Data.Length));
            MazeDebug.WriteLine(String.Format("Caminho: {0}", String.Join("", individuo.Data)));
        }
    }
}
